package com.liao.ten.moive;

import android.view.View;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

import com.liao.ten.R;
import com.liao.ten.utils.ContentUtils;
import com.squareup.picasso.Picasso;

public class ItemMovieLayoutFragment extends Fragment {

    private ImageView imgMovieImage;
    private TextView tvMovieTitle;
    private TextView tvMovieAuthor;
    private TextView tvMovieTimes;
    private TextView tvMovieText1;
    private ImageView imgMovieImage1;
    private TextView tvMovieText2;
    private TextView tvMovieRealtitle;
    private ImageView imgMovieImage2;
    private TextView tvMovieText3;
    private TextView tvMovieText4;
    private TextView tvMovieText5;
    private ImageView imgMovieImage3;
    private ImageView imgMovieImage4;
    private TextView tvMovieAuthor1;
    private TextView tvMovieAuthorBrief;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.item_moive_layout, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        imgMovieImage = (ImageView) view.findViewById(R.id.img_movie_image);
        tvMovieTitle = (TextView) view.findViewById(R.id.tv_movie_title);
        tvMovieAuthor = (TextView) view.findViewById(R.id.tv_movie_author);
        tvMovieTimes = (TextView) view.findViewById(R.id.tv_movie_times);
        tvMovieText1 = (TextView) view.findViewById(R.id.tv_movie_text1);
        imgMovieImage1 = (ImageView) view.findViewById(R.id.img_movie_image1);
        tvMovieText2 = (TextView) view.findViewById(R.id.tv_movie_text2);
        tvMovieRealtitle = (TextView) view.findViewById(R.id.tv_movie_realtitle);
        imgMovieImage2 = (ImageView) view.findViewById(R.id.img_movie_image2);
        tvMovieText3 = (TextView) view.findViewById(R.id.tv_movie_text3);
        tvMovieText4 = (TextView) view.findViewById(R.id.tv_movie_text4);
        tvMovieText5 = (TextView) view.findViewById(R.id.tv_movie_text5);
        imgMovieImage3 = (ImageView) view.findViewById(R.id.img_movie_image3);
        imgMovieImage4 = (ImageView) view.findViewById(R.id.img_movie_image4);
        tvMovieAuthor1 = (TextView) view.findViewById(R.id.tv_movie_author1);
        tvMovieAuthorBrief = (TextView) view.findViewById(R.id.tv_movie_authorBrief);

        Bundle bundle = getArguments();
        MovieInfo.ResultBean resultBean = (MovieInfo.ResultBean) bundle.getSerializable("data1");
        MovieDetailInfo movieDetailInfo = (MovieDetailInfo) bundle.getSerializable("data2");
        tvMovieTitle.setText(resultBean.getTitle());
        tvMovieRealtitle.setText(movieDetailInfo.getTitleforplay());
        tvMovieAuthor.setText(movieDetailInfo.getAuthor());
        tvMovieAuthor1.setText(movieDetailInfo.getAuthor());
        tvMovieAuthorBrief.setText(movieDetailInfo.getAuthorbrief());
        tvMovieTimes.setText(String.valueOf(movieDetailInfo.getTimes()));
        Picasso.get().load(ContentUtils.PICTURE_DISPLAY_URL+resultBean.getImage()).into(imgMovieImage);
        Picasso.get().load(ContentUtils.PICTURE_DISPLAY_URL+movieDetailInfo.getImage1()).into(imgMovieImage1);
        Picasso.get().load(ContentUtils.PICTURE_DISPLAY_URL+movieDetailInfo.getImage2()).into(imgMovieImage2);
        Picasso.get().load(ContentUtils.PICTURE_DISPLAY_URL+movieDetailInfo.getImage3()).into(imgMovieImage3);
        Picasso.get().load(ContentUtils.PICTURE_DISPLAY_URL+movieDetailInfo.getImage4()).into(imgMovieImage4);
        tvMovieText1.setText(movieDetailInfo.getText1());
        tvMovieText2.setText(movieDetailInfo.getText2());
        tvMovieText3.setText(movieDetailInfo.getText3());
        tvMovieText4.setText(movieDetailInfo.getText4());
        tvMovieText5.setText(movieDetailInfo.getText5());
    }

}
